//
//  AuditAPI.swift
//  ANOA
//
//  Created by 邱仙凯 on 2022/9/6.
//  Copyright © 2022 zwb. All rights reserved.
//

import UIKit
import Moya

public enum OriAuditAPI {
    
    // 新审批流 --------------------------------------
    
    case getWaitEventOutTip(page:String,count:String)
    case getWaitEventTip(page:String,count:String)
    case newSubmit(vou_no:String,voc_cd:String,flow_nm:String,vou_id:String,deptId:String = "",unitId:String = "")
    case newResubmit(vou_no:String,voc_cd:String,flow_nm:String,vou_id:String,deptId:String = "",unitId:String = "")
    case getFlowPicByVocVou(voc_cd:String,vou_id:String)
    
    // 根据流程id获取流程图
    case getFlowPic(process:String)
    
    // 再审的    流程id获取审核信息
    case getAuditInfoByProcess(process:String, voc_cd: String)
    // 审核完的     获取 审核信息
    case updateSubmitWaitInfoNew(process:String)
    //  用id 获取审核信息
    case getSubmitWaitInfoByVouidVoc(vou_id:String,voc_cd:String)
    
    
    // 获取转办人
    case getSendWorkAccStaff(key_word:String)
    //  审批前获取审批需要的乱七八糟的数据
    case getVouShowInfoNew(proc_inst_id:String, voc_cd: String)
    
    
    
    
    // 审批
    case eventAudit(vou_no:String,voc_cd:String,process:String,memo:String,vou_id:String,staff_nm:String,post_nm:String,post_id:String,staff_id:String,verify_mark:String,audit_id:String,audit_dt:String,task_id:String,flow_var:String,dept_id:String,unit_id:String)
    // 转办
    
    case eventSendWork(vou_no:String,voc_cd:String,process:String,vou_id:String,acc_staff_id:String,send_dt:String,send_post_id:String,audit_id:String,task_id:String,memo:String)
    case getAuditVoucherLinkForm(id_key:String,vou_cd:String,vou_id:String)

    case getAuditVoucherTyV2(id_key:String,vou_cd:String)
    case getAuditApprovaFile(id_key:String,file_name:String)
    
    
    
    case getHasNoticeInfo(voc_cd:String,unit_id:String,dept_id:String)
    case getNoticeInfo(voc_cd:String,unit_id:String,dept_id:String)
    case selectNoticeMan(unit_id:String)
    case saveVouNoticeInfo(voc_cd:String,vou_id:String,staff_id:String,data:String)

    
}

extension OriAuditAPI: TargetType {
    
    public var headers: [String : String]? {
       
            return getBaseInfoDic()
    
        
    }
    
    public var baseURL: URL {
       
            return URL(string: HTTPStr)!
         
    }
    
    
    public var path: String {
        switch self {
       
        case .newSubmit:
            return "/atvwk/event/submit"
        case .newResubmit:
            return "/atvwk/event/resubmit"
        case .getFlowPicByVocVou:
            return "/atvwk/event/getFlowPicByVocVou"
        case .getWaitEventOutTip:
            return "/atvwk/event/getWaitEventRuleOutTip"
        case .getWaitEventTip:
            return "/atvwk/event/getMakerTip"
        case .getFlowPic:
            return "/atvwk/event/getFlowPic"
        case .getAuditInfoByProcess:
            return "/atvwk/event/getAuditInfoByProcess"
        case .getSendWorkAccStaff:
            return "/atvwk/event/getSendWorkAccStaff"
        case .eventAudit:
            return "/atvwk/event/audit"
        case .getVouShowInfoNew:
            return "/atvwk/event/getVouShowInfoNew"
        case .eventSendWork:
            return "/atvwk/event/sendWork"
        case .updateSubmitWaitInfoNew:
            return "/atvwk/event/updateSubmitWaitInfoNew"
        case .getSubmitWaitInfoByVouidVoc:
            return "/atvwk/event/getSubmitWaitInfoByVouidVoc"
        case .getAuditVoucherLinkForm:
            return "/atvwk/event/getAuditVoucherLinkForm"
        case .getAuditVoucherTyV2:
            return "/atvwk/event/getAuditVoucherTyV2"
        case .getAuditApprovaFile:
            return "/atvwk/event/getAuditApprovaFile"
     
      
        case .getHasNoticeInfo:
            return "/atvwk/event/getHasNoticeInfo"
        case .getNoticeInfo:
            return "/atvwk/event/getNoticeInfo"
        case .selectNoticeMan:
            return "/atvwk/event/selectNoticeMan"
        case .saveVouNoticeInfo:
            return "/atvwk/event/saveVouNoticeInfo"
        }
        
        // MARK: -  path  尾部
    }
    
    public var method: Moya.Method { return .post }
    public var task: Task {
        
        switch self {
            
        case .newSubmit(let vou_no,let voc_cd,let flow_nm,let vou_id,let deptId,let unitId),
             .newResubmit(let vou_no,let voc_cd,let flow_nm,let vou_id,let deptId,let unitId):
            var paDic:[String:Any]!
            if unitId.isEmpty {
                paDic = ["vou_no": vou_no,"voc_cd": voc_cd,"flow_nm": flow_nm,"vou_id":vou_id]
            } else {
                paDic = ["vou_no": vou_no,"voc_cd": voc_cd,"flow_nm": flow_nm,"vou_id":vou_id,"dept_id":deptId,"unit_id":unitId]
            }
             
            return .requestParameters(parameters: paDic, encoding: URLEncoding.default)
        default:
            let rrr = testXXX(self)
             let ooo =  Mirror(reflecting: self)
            if let ddd = rrr as? [String:Any] {
                let dic = ddd[ooo.children.first?.label ?? ""]! as! [String : Any]
                return .requestParameters(parameters: dic, encoding: URLEncoding.default)
            } else {
                return .requestPlain
            }

        }
        // MARK: -  参数  尾部
    }
    
    public var sampleData: Data {
        return "{}".data(using: String.Encoding.utf8)!
    }
 
    
}
